﻿using System;

namespace ConsoleApplication16
{
    class FactorialProgram
    {
        public static void Main2()
        {
            Console.WriteLine(Factorial().Skip(5)().Value);
        }

        private static Chain<int> Factorial(int k = 0, int fac = 1)
        {
            return () => Unit.Create(fac, Factorial(k + 1, fac*(k + 1)));
        }
    }
}